#ifndef ONE_CODE_ITF_READER_H
#define ONE_CODE_ITF_READER_H



#include <onedcodefinder.h>
#include <imagebitarray.h>
#include <imageresult.h>


class OneDCodeITFFinder : public OneDCodeFinder {
private:
  enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 420/1000)};
  enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 780/1000)};
  // Stores the actual narrow line width of the image being decoded.
  int narrowLineWidth;
			
  Range decodeStart(ImageRef<ImageBitArray> row);
  Range decodeEnd(ImageRef<ImageBitArray> row);
  static void decodeMiddle(ImageRef<ImageBitArray> row, int payloadStart, int payloadEnd, std::string& resultString);
  void validateQuietZone(ImageRef<ImageBitArray> row, int startPattern);
  static int skipWhiteSpace(ImageRef<ImageBitArray> row);
			
  static Range findGuardPattern(ImageRef<ImageBitArray> row, int rowOffset, std::vector<int> const& pattern);
  static int decodeDigit(std::vector<int>& counters);
			
  void append(char* s, char c);
public:
  ImageRef<ImageResult> doDecode(ImageRef<ImageBitmap> image, int rowStep=5,int maxLines=15);

  ImageRef<ImageResult> decodeRow(int rowNumber, ImageRef<ImageBitArray> row, ImageCodeTypes itypes);
  OneDCodeITFFinder();
  ~OneDCodeITFFinder();
};



#endif // ONE_CODE_ITF_READER_H

